package com.bluedot.factory.simple;

import com.bluedot.factory.product.AddOperation;
import com.bluedot.factory.product.MultiplyOperation;
import com.bluedot.factory.product.Operation;
import com.bluedot.factory.product.SubOperation;

/**
 * @Auther: 我爱双面奶
 * @Date: 2018/7/17 16:54
 * @Description: 简单工厂实现
 */
public class SimpleFactory {
    //定义操作接口对象
    public static Operation operation = null;

    /**
     * 创建具体操作接口对象方法
     * @param operationName 操作名字
     * @return 具体操作对象
     */
    public static Operation createOperation(String operationName){
         switch (operationName){
             case "+":
                 operation = new AddOperation();
                 break;
             case "-":
                 operation = new SubOperation();
                 break;
             case "*":
                 operation = new MultiplyOperation();
                 break;
         }
         return  operation;
    }
}
